import React, { Component } from 'react'
import { Text, View ,Image} from 'react-native'
import request from '../../../utils/request'
import {FRIENDS_VISITORS,BASE_URL} from '../../../utils/pathMap'
import { pxToDp } from '../../../utils/stylesKits'
export default class Visitors extends Component {
    state = {
        vistors:[]
    }
    async componentDidMount(){
        const res = await request.privateGet(FRIENDS_VISITORS)
        if(res.code==='10000'){
            this.setState({vistors:res.data})
        }
    }
    render() {
        const {vistors} = this.state
        return (
            <View style={{
                paddingLeft:pxToDp(5),
                paddingRight:pxToDp(5),
                flexDirection:'row',
                marginTop:pxToDp(20),
                alignItems:'center',
                justifyContent:'center',
            }}>
                <Text style={{color:'#777',flex:1,fontSize:pxToDp(15),textAlignVertical:'center'}}>最近有{vistors.length}人来访,快去查看...</Text>
                <View style={{
                    flexDirection:'row',
                    flex:1,
                    alignItems:'center'
                }}>
                    {
                        vistors.map((v,i)=>{
                            return (
                                <Image
                                    style={{
                                        width:pxToDp(40),
                                        height:pxToDp(40),
                                        borderRadius:pxToDp(20)
                                    }}
                                    source={{uri:BASE_URL+v.header}}
                                ></Image>
                            )
                        })
                    }
                </View>
                <Text style={{color:'#777',fontSize:pxToDp(20)}}>&gt;</Text>
            </View>
        )
    }
}
